package com.biz.primus.ms.order.stream;

import com.biz.primus.model.oms.enums.OrderState;
import com.biz.primus.model.oms.stream.OrderStateChannel;
import org.springframework.cloud.stream.annotation.Output;
import org.springframework.messaging.MessageChannel;

/**
 * @author yanweijin
 * @date 2017/11/6
 */
public interface OrderStateSource extends OrderStateChannel{



	@Output(ORDER_BEGIN)
	MessageChannel orderBeginOutput();
	
	@Output(ORDER_OUTBOUND)
	MessageChannel orderOutboundOutput();

	@Output(ORDER_FINISHED)
	MessageChannel orderFinishedOutput();

    /**
     * 订单取消
     * @return
     */
	@Output(ORDER_CANCEL)
	MessageChannel orderCancelOutput();

//	@Output(REFUND)
//	MessageChannel refund();

	/**
	 * 根据订单状态获取对应渠道
	 * @param state
	 * @return
	 */
	default MessageChannel getChannelByOrderState(OrderState state){
		switch (state) {
			case begin:         return orderBeginOutput();
//			case allocated:
//			case printed:
			case outbound:      return orderOutboundOutput();
			case finished:      return orderFinishedOutput();
			default:
				throw new IllegalArgumentException("暂时不支持这些通道:"+state);
		}
	}



}
